﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bukstor.Biz;

namespace Bukstor.Admin.UI
{
    public partial class LogIn : System.Web.UI.Page
    {
        BukstorBDEntities Entidades;

        protected void Page_Load(object sender, EventArgs e)
        {
            Entidades = new BukstorBDEntities();
            if (!Page.IsPostBack&&Request.UrlReferrer!=null)
            {
                logInEmpleados.DestinationPageUrl = Request.UrlReferrer.AbsoluteUri;
            }
        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            IEnumerable<Empleado> C = from Empleado E in Entidades.Empleados
                                      where E.username == logInEmpleados.UserName && E.password == logInEmpleados.Password
                                      select E;
            bool valido = C.Count() == 1;
            e.Authenticated = valido;
        }
    }
}
